﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace LevelEditor.Model.Entity
{
    [Serializable]
    public class Layer : INotifyPropertyChanged
    {
        // Fields
        private bool isItemLocked;
        private bool isItemVisible;

        // Events
        public event PropertyChangedEventHandler PropertyChanged;

        public Layer()
        {
            this.GameSprites = new List<GameSprite>();
            PhysicBodies = new List<PhysicBody>();
        }

        private void NotifyPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        // Properties
        [XmlArray]
        public List<GameSprite> GameSprites { get; set; }

        public string Icon { get; set; }

        public bool IsItemLocked
        {
            get
            {
                return this.isItemLocked;
            }
            set
            {
                this.isItemLocked = value;
                for (int i = 0; i < this.GameSprites.Count; i++)
                {
                    this.GameSprites[i].IsItemLocked = this.isItemLocked;
                }
                this.NotifyPropertyChanged("IsItemLocked");
            }
        }

        public bool IsItemVisible
        {
            get
            {
                return this.isItemVisible;
            }
            set
            {
                this.isItemVisible = value;
                for (int i = 0; i < this.GameSprites.Count; i++)
                {
                    this.GameSprites[i].IsItemVisible = this.isItemVisible;
                }
                this.NotifyPropertyChanged("IsItemVisible");
            }
        }

        public string Name { get; set; }

        [XmlArray]
        public List<PhysicBody> PhysicBodies { get; set; }
    }


}
